(backtrace--print-func-and-args): Fix (part of) bug#70436
authorStefan Monnier <monnier@iro.umontreal.ca>
Sat, 20 Apr 2024 15:23:58 +0000 (11:23 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sat, 20 Apr 2024 15:23:58 +0000 (11:23 -0400)
commit0536b96011d24797d16d97a59a62f633a3d30472
treeabbeb4bcbae562da6e0f5db2d910576942682045
parent24ea3024ae241d1fc5fb3e05d584211070b73d5d
(backtrace--print-func-and-args): Fix (part of) bug#70436

The source of bug#70436 is that we print a value into the buffer
and then we generate its print representation a second time to
get its length to find the bounds of the thing we just printed.
Not only it's wasteful, but it risks bugs because the two
"prints" can be inconsistent with each other.

This is not a complete fix because in the non EVALD case we
still use that same broken way.

* lisp/emacs-lisp/backtrace.el (backtrace--print-func-and-args):
Don't re-print things just to get their length.
(backtrace--print-to-string): Skip a temp-buffer indirection.
lisp/emacs-lisp/backtrace.el